import { Module } from 'vuex';
import { RootState } from '../types';
interface UserState {
    firstName: string;
    lastName: string;
    email: string;
    phone?: string;

}
export const state: UserState = {
    firstName: '王',
    lastName: '小明',
    email: '',
    phone: '',
};
const namespaced: boolean = true;
export const user: Module<UserState, RootState> = {
    namespaced,
    state,
    getters:{
        fullName(state): string {
            return state.firstName + state.lastName;
        }
    },
    actions: {
        updateFirstName({ commit }, payload) {
            commit('updateFirstName', payload);
        }
    },
    mutations: {
        updateFirstName(state, payload) {
            state.firstName = payload;
        }
    }
};
